package com.knowledge.plus.aop.controller;

import com.knowledge.plus.aop.annotation.Log;
import com.knowledge.plus.aop.annotation.MethodAnnotation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 自定义注解测试
 *
 * @author PF.Tian
 * @since 2021/09/13
 */
@RestController
public class AnnotationTestController {

    @MethodAnnotation
    @PostMapping("aop-test")
    public String aopTest(@RequestParam("param") String param) {
        System.out.println("...do something..." + param);
        return "Hello World！";
    }

    @MethodAnnotation
    @GetMapping("exception-test")
    public String exceptionTest() {
        String str = null;
        System.out.println(str.indexOf(3));
        return "运行结束！";
    }

    @Log(title = "日志测试")
    @GetMapping("log-test")
    public String logTest(HttpServletRequest request) {
        return "log";
    }

}
